package net.uman.entity;

import java.util.Date;

import org.springframework.security.authentication.encoding.Md5PasswordEncoder;

import net.uman.entity.IdEntity;



/**
 * 用户
 */
public class User extends IdEntity {
	private static final long serialVersionUID = 1L;
	
	private Integer type;
	private String loginName;
	private String password;//为简化演示使用明文保存的密码
	private String name;
	private String phone;
	private String email;
	private Date addDate;
	private Integer point; //积分
	private String photoUrl; //头像
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	
	public String encodePassword(String pwd) {
		return new Md5PasswordEncoder().encodePassword(pwd, getLoginName());
	}
	public String getLoginName() {
		return loginName;
	}
	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public Integer getPoint() {
		return point;
	}
	public void setPoint(Integer point) {
		this.point = point;
	}
	public String getPhotoUrl() {
		return photoUrl;
	}
	public void setPhotoUrl(String photoUrl) {
		this.photoUrl = photoUrl;
	}
	
	public static void main(String[] args) {
		User user = new User();
		user.setLoginName("admin");
		System.out.println(user.encodePassword("123"));
	}
	public Date getAddDate() {
		return addDate;
	}
	public void setAddDate(Date addDate) {
		this.addDate = addDate;
	}

	//字段非空且唯一, 用于提醒Entity使用者及生成DDL.
}